
public class CliffFeature implements Feature {

	@Override
	public double computeScore(Stateview s) {
		int[] top = s.getTop();
		
		int sum = 0;
		
		// first column
		if (top[0]<top[1])
			sum -= Math.pow(top[1] - top[0], 3);
		
		// identify the cliffs and sum them up
		for(int col=1; col<top.length-1; col++) {
			if(top[col]<top[col+1] && top[col]<top[col-1]) {
				if(top[col+1] < top[col])
					sum -= Math.pow(top[col+1] - top[col], 3);
				else
					sum -= Math.pow(top[col-1] - top[col], 3);
			}
		}
		
		// last column
		if (top[top.length-1]<top[top.length-2])
			sum -= Math.pow(top[top.length-2] - top[top.length-1],3);
		
		return sum;
	}

	
	
}
